from database_test import Singers,db

def add_singers(Sid,Sname,Sage) :
	# 利用Singers模型初始化一个 Singers对象
	singers1 = Singers(Sid = Sid,Sname = Sname,Sage = Sage)
	# 添加该对象
	db.session.add(singers1)
	# 提交会话
	db.session.commit()
	
def delete_singers(Sname) :
	# 找到删除对象
	singers2 = Singers.query.filter(Singers.Sname == Sname).first()
	# 删除该对象
	db.session.delete(singers2)
	# 提交会话
	db.session.commit()
	
def search_singers(Sname) :
	# 找到查询对象并返回
	singers3 = Singers.query.filter(Singers.Sname == Sname).first()
	return singers3

def alter_singers(Sname,Sage) :
	# 找到修改对象
	singers4 = Singers.query.filter(Singers.Sname == Sname).first()
	# 对年龄进行修改
	singers4.Sage = Sage
	# 提交会话
	db.session.commit()